import React, { useEffect, useState } from "react";

export default function UserInput() {
  const [state, setState] = useState({ name: '', age: '' });
  const { name, age } = state;
  useEffect(() => {
    console.log('age:===>', name)
  }, [name])

  return (
    <div>
      <input
        type="number"
        value={age}
        placeholder="Enter age"
        onChange={e => setState({ ...state, age: e.target.value })}
      />
      <p>
        <strong>My Age : {age}</strong>
      </p>
      <input
        type="text"
        value={name}
        placeholder="Enter name"
        onChange={e => setState({...state, name: e.target.value})}
      />
      <p>
        <strong>My Name : {name}</strong>
      </p>
    </div>
  );
};